<?php
use Yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;

$this->title = '注册设置';
?>
<div class="container">
    <div class="row">
      
       <?php echo $this->render('_leftnav') ?>
        <div class="col-md-10">
          <div class="page-header clearfix">
            <h1 class="pull-left">注册</h1>
            <div class="pull-right">

                                            
            </div>
          </div>
            <?php echo $this->render('_usersetting') ?>

	<?php
	$form = ActiveForm::begin([
		'options' => ['class' => 'form-horizontal','id'=>'auth-form'],
		'action'=>Url::to(['system/userregsave']),
		'method'=>'post',
		'fieldConfig' => [
			'template' => '<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8">{input}{error}</div></div>'
		],
	]);
	?>

  <fieldset>
    <legend>注册设置</legend>
    <div class="form-group">
      <div class="col-md-3 control-label">
        <label>用户注册模式</label>
      </div>
      <div class="controls col-md-8">
        <div class="btn-group">
          <button type="button" class="btn btn-default btn-primary email" data-modle="email">邮箱注册</button>
          <button type="button" class="btn btn-default  model phone" data-modle="mobile">手机注册</button>
        </div>
        <input value="email" name="register_mode" type="hidden">
        <div class="help-block">开启云短信后，才可使用“手机注册”或“邮箱或手机注册”</div>
      </div>
    </div>

    
    <div class="email-content " style="display:block">

	    <?= $form->field($model, 'email_title', ['inputOptions'=>['placeholder'=>'请激活您的{{sitename}}账号']])->textInput() ?>

	    <?= $form->field($model, 'email_content', ['inputOptions'=>['placeholder'=>'Hi, {{nickname}}欢迎加入{{sitename}}!请点击下面的链接完成注册：{{verifyurl}}如果以上链接无法点击，请将上面的地址复制到你的浏览器(如IE)的地址栏中打开，该链接地址24小时内打开有效。感谢对{{sitename}}的支持！{{sitename}} {{siteurl}}(这是一封自动产生的email，请勿回复。)'],'template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8">{input}{error}<div class="help-block"><div>变量说明：</div><ul><li>{{nickname}} 为接收方用户昵称</li><li>{{sitename}} 为网站名称</li><li>{{siteurl}} 为网站的地址</li><li>{{verifyurl}} 为邮箱验证地址</li></ul></div></div></div>'])->textarea(['rows'=>3]) ?>

    </div>

	  <div class="phone-content " style="display:none">

		  <?= $form->field($model, 'phone_content', ['inputOptions'=>['placeholder'=>'Hi, {{nickname}}欢迎加入{{sitename}}!请输入下面的验证码完成注册：{{verifyurl}},该验证码半小时内有效。感谢对{{sitename}}的支持！'],'template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8">{input}{error}<div class="help-block"><div>变量说明：</div><ul><li>{{nickname}} 为接收方用户昵称</li><li>{{sitename}} 为网站名称</li><li>{{verifyurl}} 为生成的验证码</li></ul></div></div></div>'])->textarea(['rows'=>3]) ?>

	  </div>


    <div class="form-group">

	    <?= $form->field($model, 'email_protect',['template'=>'<div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}</div>'])->radioList(['0'=>'无','1'=>'低','2'=>'中','3'=>'高'],["class"=>"protect"]) ?>

      <div class="controls col-md-8 mtl 1 register-help  col-md-offset-3" style="display:none;">
        <div class="well">
          方案说明：
          <p class="mll mtm">1：注册时需填写验证码。</p>
        </div>
      </div>

      <div class="controls col-md-8 mtl 2 register-help  col-md-offset-3" style="display:none;">
        <div class="well">
          方案说明：
          <p class="mll mtm">1：注册时需填写验证码。</p>
          <p class="mll mtm">2：同一IP24小时內只能注册30次。</p>
        </div>
      </div>

      <div class="controls col-md-8 mtl 3 register-help  col-md-offset-3" style="display:none;">
        <div class="well">
          方案说明：
          <p class="mll mtm">1：注册时需填写验证码。</p>
          <p class="mll mtm">2：同一IP24小时內只能注册10次。</p>
          <p class="mll mtm">3：同一IP1小时內只能注册1个账号。</p>
        </div>
      </div>
    </div>

  </fieldset>

  <fieldset>
    <legend>欢迎信息设置</legend>
	  <?= $form->field($model, 'welcome_message',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<div class="help-block">欢迎信以站内私信的方式，发送给新用户。</div></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

	  <?= $form->field($model, 'welcome_sender')->textInput() ?>

	  <?= $form->field($model, 'welcome_title',['inputOptions'=>['placeholder'=>'欢迎加入{{sitename}}']])->textInput() ?>
	  <?= $form->field($model, 'welcome_content',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8">{input}{error}<div class="help-block"><div>注意： 私信长度不能超过1000个字符</div><div>变量说明：</div><ul><li>{{nickname}} 为接收方用户用户名</li><li>{{sitename}} 为网站名称</li><li>{{siteurl}} 为网站的地址</li></ul></div></div></div>','inputOptions'=>['placeholder'=>'您好{{nickname}}，我是{{sitename}}的管理员，欢迎加入{{sitename}}，祝您学习愉快。如有问题，随时与我联系。']])->textarea() ?>
  </fieldset>

  <fieldset>
    <legend>服务条款设置</legend>
	  <?= $form->field($model, 'service_status')->radioList(['1'=>'开启','0'=>'关闭']) ?>

	  <?= $form->field($model, 'service_content')->textarea(['style'=>'visibility: hidden; display: none;','class'=>'form-control','id'=>'user_terms_body','rows'=>'16']) ?>

  </fieldset>

  <div class="form-group">
    <div class="col-md-3 control-label"></div>
    <div class="controls col-md-8">
	    <?= Html::submitButton('提交', ['class'=>'btn btn-primary']) ?>
    </div>
  </div>
	<?php ActiveForm::end(); ?>

        </div>

          </div>
  </div>
<?= Html::jsFile('/assets/ckeditor/ckeditor.js')?>
<script>CKEDITOR.replace('user_terms_body')</script>
<script>
	/**
	 * 注册防护机制
	 */
	$(document).on("click",".protect div label input",function(){
		var val = $(this).val();
			if(val == 0){
				$(".1").css("display",'none');
				$(".2").css("display",'none');
				$(".3").css("display",'none');
			}else{
				if(val == 1){
					$(".2").css("display",'none');
					$(".3").css("display",'none');
				}else if(val == 2){
					$(".1").css("display",'none');
					$(".3").css("display",'none');
				}else{
					$(".1").css("display",'none');
					$(".2").css("display",'none');
				}
				$("."+val).css("display","block");
			}
	})

	/**
	 * 邮箱，手机注册
	 */
	$(".email").click(function(){
		$(".email-content").css("display","block");
		$(".phone-content").css("display","none");
		$(".phone").attr("class","btn btn-default phone");
		$(this).attr("class","btn btn-default btn-primary email");
	})
	$(".phone").click(function(){
		$(".email-content").css("display","none");
		$(".phone-content").css("display","block");
		$(".email").attr("class","btn btn-default email");
		$(this).attr("class","btn btn-default btn-primary phone");
	})
</script>
